package core.collection.mymap;

import java.util.HashMap;
import java.util.Map;

/**
 * 统计字符串中每个字符出现的次数
 *
 * @author
 * @create 2018-12-23 12:44
 **/
public class mymap_6_Map_Str {
    public static void main(String[] args) {
        String test = "aaabbbbccccccccccc";
        char[] a = test.toCharArray();
        Map<Character,Integer> map = new HashMap<>();
        for(int i=0;i<a.length;i++){
            if(map.containsKey(a[i])){
                map.put(a[i],map.get(a[i])+1);
            }else{
                map.put(a[i],1);
            }
        }
        System.out.println(map);
    }
}
